<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
  </body>
  <script type="text/javascript">
    
    var list = [
      {
        courseDate: '2021-7-8',
        week: '',
        dlsTeachingCalendarResponseList: [
          {
            date: '07月1号',
            week: '4',
            cclass: '3-504',
            teachingContent: '傅里叶级数',
            lecturer: '朱家裕',
            lnstructor: '我',
            cname: '《高等数学》',
            classroom: '数学教研室',
            guidefaculty: '',
            studentClass: '1队3班',
            teachlocation: '3-604',
            startClass: '1',
            endClass: '2',
            rowspan: 0,
            colspan: 0,
          },
          {
            date: '07月1号',
            week: '2',
            cclass: '3-504',
            teachingContent: '傅里叶级数',
            lecturer: '朱家裕',
            lnstructor: '我',
            cname: '《高等数学》',
            classroom: '数学教研室',
            guidefaculty: '',
            studentClass: '1队3班',
            teachlocation: '3-604',
            startClass: '1',
            endClass: '2',
            rowspan: 0,
            colspan: 0,
          }
        ]
      }
    ];
    function tableData1() {
      let tableList = [];
      for(let i of this.list) {
        if(!!!i.dlsTeachingCalendarResponseList) {
          continue;
        }
        for(j = 0; j < i.dlsTeachingCalendarResponseList.length; j++) {
          i.dlsTeachingCalendarResponseList[j].rowspan = j == 0 ? i.dlsTeachingCalendarResponseList.length : 0 ;
          i.dlsTeachingCalendarResponseList[j].colspan = 0;
          tableList.push(i.dlsTeachingCalendarResponseList[j]);
        }
      }
      console.log('tableList1+++++++', tableList);
      return tableList;
    }
    tableData1();
    function tableData2() {
      let weekDayKeys = ['ri', 'yi', 'er', 'san', 'si', 'wu', 'liu'];
      let tableList = [];
      for(let i = 0; i < this.list.length; i++) {
        for(let item of this.list[i].dlsTeachingCalendarResponseList) {
          let data = tableList.find(o => o.jie == item.startClass + '-' + item.endClass)
          if(!!data) {
            data[weekDayKeys[item.week]] = item.teachingContent + ',' + item.lecturer + ',' + item.classRoom + ',' + item.cname;
          } else {
            tableList.push({
              'jie': item.startClass + '-' + item.endClass,
              [weekDayKeys[item.week]]: item.teachingContent + ',' + item.lecturer + ',' + item.classRoom + ',' + item.cname
            });
          }
        }
      }
      console.log('tableList2+++++++', tableList);
      return tableList;
    }
    tableData2();
    let a = null;
    let b = a || 0;
    alert(b)
  </script>
</html>
